package com.ruoyi.web.controller.job;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.JobDetailedListMaintain;
import com.ruoyi.system.domain.vo.DeleteVo;
import com.ruoyi.system.service.JobDetailedListMaintainService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 风险作业分级清单维护(JobDetailedListMaintain)表控制层
 * @since 2022-11-23 09:19:58
 */
@Slf4j
@RestController
@Api(tags = "风险作业分级清单维护")
@RequestMapping("job/detailed/list/maintain")
public class JobDetailedListMaintainController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private JobDetailedListMaintainService jobDetailedListMaintainService;

    /**
     * 分页查询
     *
     * @param jobDetailedListMaintain 筛选条件
     * @return 查询结果
     */
    @GetMapping("list")
    @ApiOperation("获取列表")
    public TableDataInfo queryByPage(JobDetailedListMaintain jobDetailedListMaintain) {
        startPage();
        List<JobDetailedListMaintain> list = jobDetailedListMaintainService.queryAll(jobDetailedListMaintain);
        return getDataTable(list);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    @ApiOperation("获取详情")
    public ResponseEntity<JobDetailedListMaintain> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.jobDetailedListMaintainService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param jobDetailedListMaintain 实体
     * @return 新增结果
     */
    @PostMapping("add")
    @ApiOperation("新增")
    public ResponseEntity<JobDetailedListMaintain> add(@Validated @RequestBody JobDetailedListMaintain jobDetailedListMaintain) {
        return ResponseEntity.ok(this.jobDetailedListMaintainService.insert(jobDetailedListMaintain));
    }

    /**
     * 编辑数据
     *
     * @param jobDetailedListMaintain 实体
     * @return 编辑结果
     */
    @PutMapping("edit")
    @ApiOperation("修改")
    public ResponseEntity<JobDetailedListMaintain> edit(@Validated @RequestBody JobDetailedListMaintain jobDetailedListMaintain) {
        return ResponseEntity.ok(this.jobDetailedListMaintainService.update(jobDetailedListMaintain));
    }

    /**
     * 删除数据
     *
     * @param deleteVo 主键
     * @return 删除是否成功
     */
    @DeleteMapping("delete")
    @ApiOperation("删除")
    public ResponseEntity<Boolean> deleteById(@Validated @RequestBody DeleteVo deleteVo) {
        return ResponseEntity.ok(this.jobDetailedListMaintainService.deleteById(deleteVo.getId()));
    }

}

